package com.anmingle.common;

import com.anmingle.enums.ErrorCode;
import com.fasterxml.jackson.annotation.JsonInclude;


/**
 * @author 安明乐
 * 返回类
 * //如果加该注解的字段为null,那么就不序列化这个字段了
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseResult<T> {
    /**
     * 状态码
     */
    private Integer code;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    /**
     * 提示信息，如果有错误时，前端可以获取该字段进行提示
     */
    private String msg;
    /**
     * 查询到的结果数据，
     */
    private T result;


    public ResponseResult(ErrorCode code) {
        this(code.getCode(), code.getMessage(),null);
    }

    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(Integer code, T result) {
        this.code = code;
        this.result = result;
    }

    public ResponseResult(Integer code, String msg, T result){
        this.code = code;
        this.msg = msg;
        this.result = result;
    }


}